home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / exec / openlibrary.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  107 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openlibrary.c,v 1.5 1996/10/24 15:50:53 aros Exp $
  4.     $Log: openlibrary.c,v $
  5.     Revision 1.5  1996/10/24 15:50:53  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:05  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:15  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include <exec/execbase.h>
  20. #include <exec/lists.h>
  21. #include <aros/libcall.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <exec/libraries.h>
  27.     #include <clib/exec_protos.h>
  28.  
  29.     AROS_LH2(struct Library *, OpenLibrary,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(UBYTE *, libName, A1),
  33.     AROS_LHA(ULONG,   version, D0),
  34.  
  35. /*  LOCATION */
  36.     struct ExecBase *, SysBase, 92, Exec)
  37.  
  38. /*  FUNCTION
  39.     Opens a library given by name and revision. If the library
  40.     doesn't exist in memory it is tried to load it from disk.
  41.     It this fails too, NULL is returned.
  42.  
  43.     INPUTS
  44.     libName - Pointer to the library's name.
  45.     version - the library's version number.
  46.  
  47.     RESULT
  48.     Pointer to library structure or NULL.
  49.  
  50.     NOTES
  51.  
  52.     EXAMPLE
  53.  
  54.     BUGS
  55.  
  56.     SEE ALSO
  57.     CloseLibrary().
  58.  
  59.     INTERNALS
  60.  
  61.     HISTORY
  62.     21-10-95    digulla automatically created from
  63.                 include:clib/exec_protos.h
  64.  
  65. *****************************************************************************/
  66. {
  67.     AROS_LIBFUNC_INIT
  68.  
  69.     AROS_LIBBASE_EXT_DECL(struct ExecBase *,SysBase)
  70.     struct Library * library;
  71.  
  72.     /* Arbitrate for the library list */
  73.     Forbid();
  74.  
  75.     /* Look for the library in our list */
  76.     library = (struct Library *) FindName (&SysBase->LibList, libName);
  77.  
  78.     /* Something found ? */
  79.     if(library!=NULL)
  80.     {
  81.     /* Check version */
  82.     if(library->lib_Version>=version)
  83.     {
  84.         /* Call Open vector */
  85.         library=AROS_LVO_CALL1(struct Library *,
  86.         AROS_LCA(ULONG,version,D0),
  87.         struct Library *,library,1,
  88.         );
  89.     }else
  90.         library=NULL;
  91.     }
  92.     /*
  93.     else
  94.     {
  95.     Under normal circumstances you'd expect the library loading here -
  96.     but this is only exec which doesn't know anything about the
  97.     filesystem level. Therefore dos.library has to SetFunction() this vector
  98.     for the additional functionality.
  99.     }
  100.     */
  101.  
  102.     /* All done. */
  103.     Permit();
  104.     return library;
  105.     AROS_LIBFUNC_EXIT
  106. } /* OpenLibrary */
  107.